{% load i18n djangobmf_markup %}
<h1>{% trans "Invoice" %}: {{ object.invoice_number }} <small>{{ object.date|date:"SHORT_DATE_FORMAT" }}</small></h1>

<ol class="breadcrumb">
    {% if object.quotation %}<li><a href="{{ object.quotation.bmfmodule_detail }}">{{ object.quotation }}</a> ({% trans "Quotation" %})</li>{% endif %}
  <li><a href="{{ object.project.bmfmodule_detail }}">{{ object.project }}</a> ({% trans "Project" %})</li>
  <li><a href="{{ object.customer.bmfmodule_detail }}">{{ object.customer }}</a> ({% trans "Customer" %})</li>
  <li><a href="{{ object.employee.bmfmodule_detail }}">{{ object.employee }}</a> ({% trans "Employee" %})</li>
</ol>

{% if object.notes %}
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">{% trans "Notes" %}</h3>
  </div>
  <div class="panel-body">{{ object.notes|bmfmarkup }}</div>
</div>
{% endif %}

<div class="row">
    <div class="col-sm-6">
    {{ object.shipping_address }}
    </div>
    <div class="col-sm-6">
    {{ object.invoice_address }}
    </div>
</div>

<table class="table table-striped table-condensed table-hover">
  <thead>
    <tr>
      <th width="">{% trans "Name" %}</th>
      <th width="">{% trans "Price" %}</th>
      <th width="">{% trans "Amount" %}</th>
      <th width="">{% trans "Net" %}</th>
      <th width="">{% trans "Gross" %}</th>
      <th width="10%"></th>
    </tr>
  </thead>
  <tfoot>
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td>{{ object.calc_net }}</td>
      <td>{{ object.calc_gross }}</td>
      {% if not object.completed %}
      <td class="text-right">
          <a class="btn btn-xs bmf-edit btn-success" href="{% url "djangobmf:moduleapi_djangobmf_invoice_invoiceproduct:create" "default" %}?set-invoice={{ object.pk }}">
          <span class="glyphicon glyphicon-plus"></span>
        </a>
      </td>
      {% else %}
      <td></td>
      {% endif %}
    </tr>
  </tfoot>
  <tbody>
    {% for obj in object.get_products %}
    <tr>
      <td>
          {{ obj.name }}
      </td>
      <td>
          {{ obj.calc_net_unit }}
          {{ obj.calc_taxes }}
      </td>
      <td>
          {{ obj.amount }}
      </td>
      <td>
          {{ obj.calc_net }}
      </td>
      <td>
          {{ obj.calc_gross }}
      </td>
      <td class="text-right">
          <a class="btn btn-xs bmfedit btn-bmfupdate" href="#?set-invoice={{ object.pk }}">
            <span class="glyphicon glyphicon-wrench"></span>
          </a>
          <a class="btn btn-xs bmfedit btn-bmfdelete" href="#">
            <span class="glyphicon glyphicon-trash"></span>
          </a>
        </a>
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>

{% if object.term_of_payment %}
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">{% trans "Term of payment" %}</h3>
  </div>
  <div class="panel-body">{{ object.term_of_payment|bmfmarkup }}</div>
</div>
{% endif %}
